Skip to content

HDDS-14934. Enable ConsecutiveAppendsShouldReuse rule in PMD#10008

Merged
adoroszlai merged 5 commits intoapache:masterfrom
ptlrs:HDDS-14934-ConsecutiveAppendsShouldReuse
Apr 3, 2026
Merged

HDDS-14934. Enable ConsecutiveAppendsShouldReuse rule in PMD#10008
adoroszlai merged 5 commits intoapache:masterfrom
ptlrs:HDDS-14934-ConsecutiveAppendsShouldReuse

Conversation

@ptlrs
Copy link
Copy Markdown
Contributor

@ptlrs ptlrs commented Mar 30, 2026

What changes were proposed in this pull request?

This PR enables new PMD rules:
ConsecutiveAppendsShouldReuse Consecutive calls to StringBuffer/StringBuilder .append should be chained, reusing the target object. This can improve the performance by producing a smaller bytecode, reducing overhead and improving inlining

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-14934

How was this patch tested?

CI: https://github.com/ptlrs/ozone/actions/runs/23761982025

@ptlrs ptlrs changed the title HDDS-14934. Enable ConsecutiveAppendsShouldReuse rule in PMD HDDS-14934. Enable BigIntegerInstantiation, ConsecutiveAppendsShouldReuse rule in PMD Mar 30, 2026
@adoroszlai adoroszlai added the code-cleanup Changes that aim to make code better, without changing functionality. label Mar 31, 2026
Copy link
Copy Markdown
Contributor

@Gargi-jais11 Gargi-jais11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ptlrs for the patch.
After you raised the PR there are many places which needs changes for .append chaining in DiskBalancerReportSubcommand. Please update this as well.
Rest LGTM.

Copy link
Copy Markdown
Contributor

@adoroszlai adoroszlai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ptlrs for the patch. I would like to suggest splitting the change for BigIntegerInstantiation into a separate task. While there is only one exact violation, some other BigInteger creation can also be improved. Created HDDS-14955 for that.

@ptlrs ptlrs changed the title HDDS-14934. Enable BigIntegerInstantiation, ConsecutiveAppendsShouldReuse rule in PMD HDDS-14934. Enable ConsecutiveAppendsShouldReuse rule in PMD Apr 3, 2026
@ptlrs
Copy link
Copy Markdown
Contributor Author

ptlrs commented Apr 3, 2026

Thanks for the reviews @Gargi-jais11 @adoroszlai, I have updated the PR. Could you please take another look?

@ptlrs ptlrs requested review from Gargi-jais11 and adoroszlai April 3, 2026 02:39
@adoroszlai adoroszlai marked this pull request as ready for review April 3, 2026 13:06
Copy link
Copy Markdown
Contributor

@Gargi-jais11 Gargi-jais11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ptlrs for updating the patch. LGTM!

@adoroszlai adoroszlai merged commit 033e0bb into apache:master Apr 3, 2026
103 of 105 checks passed
@adoroszlai
Copy link
Copy Markdown
Contributor

Thanks @ptlrs for updating the patch, @Gargi-jais11 for the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-cleanup Changes that aim to make code better, without changing functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants